package com.block.applet.service.impl;

import com.alibaba.fastjson.JSONObject;
import com.block.common.constant.AppRspCodeConstant;
import com.block.common.vo.ResponseVo;
import com.block.db.entity.AppletConfigInfo;
import com.block.db.mapper.AppletConfigInfoMapper;
import com.block.applet.service.AppletConfigInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class AppletConfigInfoServiceImpl implements AppletConfigInfoService {

    @Autowired
    AppletConfigInfoMapper appletConfigInfoMapper;
    @Override
    public AppletConfigInfo selectAppletByChannelCode(String channelCode) {

        return appletConfigInfoMapper.selectAppletByChannelCode(channelCode);
    }

    @Override
    public String getChannelCode(String appid) {
        return appletConfigInfoMapper.getChannelCode(appid);
    }

    @Override
    public ResponseVo selectAppletByChannelCodeAndType(String channelCode) {
        JSONObject jsonObject = new JSONObject();
        AppletConfigInfo appletConfigInfo = appletConfigInfoMapper.selectAppletByChannelCodeAndType(channelCode);
        if(appletConfigInfo == null){
            return new ResponseVo(AppRspCodeConstant.VERIFY_CODE_ERROR, "未找到该渠道下的信息");
        }
        jsonObject.put("gzhLogo", appletConfigInfo.getGzhLogo());
        jsonObject.put("gzhQrCode", appletConfigInfo.getGzhQrCode());
        return new ResponseVo(AppRspCodeConstant.SUCCESS, jsonObject);
    }
}